﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Meeting.DBUtility;
namespace Meeting.BLL
{
    public  class MeetingTopic
    {

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.MeetingTopic GetModel(int Id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,MeetingId,Value from MeetingTopic ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)
			};
            parameters[0].Value = Id;

            Model.MeetingTopic model = new Model.MeetingTopic();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.MeetingTopic DataRowToModel(DataRow dr)
        {
            Model.MeetingTopic topic = new Model.MeetingTopic();
            if (dr != null)
            {
                if (dr["TopicId"] != null && dr["TopicId"].ToString() != "")
                {
                    topic.TopicId = new Guid(dr["TopicId"].ToString());
                }
                if (dr["MeetingId"] != null && dr["MeetingId"].ToString() != "")
                {
                    topic.MeetingId = int.Parse(dr["MeetingId"].ToString());
                }
                if (dr["RoleId"] != null && dr["RoleId"].ToString() != "")
                {
                    topic.RoleId = dr["RoleId"].ToString();
                }
                if (dr["EmployeeId"] != null && dr["Employee"].ToString() != "")
                {
                    topic.EmployeeId = dr["Employee"].ToString();
                }
                if (dr["EmployeeName"] != null && dr["EmployeeName"].ToString() != "")
                {
                    topic.EmployeeName = dr["EmployeeName"].ToString();
                }
                if (dr["EmployeeTitle"] != null && dr["EmployeeTitle"].ToString() != "")
                {
                    topic.EmployeeTitle = dr["EmployeeTitle"].ToString();
                }
                if (dr["Sort"] != null && dr["Sort"].ToString() != "")
                {
                    topic.Sort = int.Parse(dr["Sort"].ToString());
                }
                
            }
            return topic;
        }


    }
}
